package com.longge;

import java.util.Stack;

public class ReverseMessage {
    public String reverseMessage(String message) {

        Stack<String> stack = new Stack<>();
        String[] strs = message.split(" ");
        for (String str : strs) {
            stack.push(str.trim());
        }
        StringBuilder sb = new StringBuilder();
        while (!stack.isEmpty()) {
            String pop = stack.pop();
            if (!pop.equals("")) {
                sb.append(" ");
                sb.append(pop);
            }

        }
        return sb.toString().trim();
    }


}
